<%@ page import="java.util.*,com.actimind.actitime.Keys,com.actimind.actitime.reports.*,
                 org.apache.struts.util.ResponseUtils,
                 com.actimind.actitime.util.TimeUtils"%>
<%@ page errorPage="/error.jsp" %>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<at:CheckLoggedIn/>
<bean:define id="report" name="report" type="ReportInfo"/>
<bean:define id="form" name="PrepareInvoiceForm" type="PrepareInvoiceForm"/>

<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Prepare Invoice Data</title>
    <link rel="stylesheet" href="../css/at.css" type="text/css">
    <script language="JavaScript" src="../js/at.js"></script>

</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="reports"/>
    <jsp:param name="pageAction" value="prepareinvoice"/>
</jsp:include>

<table width="770" align="center" cellspacing="0" cellpadding="4" border="0">
<tr>
    <td class="pagetitle" valign="top">Prepare Invoice Data</td>
</tr>
<tr><td><at:errors/></td></tr>
<tr>
    <td><html:link page="/reports/prepareinvoice.do">
        &lt;&lt; Change report parameters
        </html:link>
    </td>
</tr>
<tr>
    <td class="text" colspan="<%=2+report.getColumns().size()%>">
        <br>
        <span class="formblocktitle">Invoice parameters:</span>
        <bean:write name="report" property="parametersString"/>
    </td>
</tr>
</table>

<table bgcolor="#CCCCCC" width="770" align="center" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<table bgcolor="#CCCCCC" width="100%" align="center" cellspacing="1" cellpadding="4" border="0">
<tr>
    <td nowrap align="center" valign="center" class="listtblcolheader">
        Billing Type
    </td>
    <td width="80%" class="listtblcolheader">
        <img src="../img/pixel.gif" width=1 height=2/>
        <br>
        <% if(form.getInvoiceType() == PrepareInvoiceForm.INVOICE_PLAIN_LIST_OF_PROJECTS) {%>
        Project
        <% } else { %>
        Project / Task
        <% } %>
        <br>
        <img src="../img/pixel.gif" width=1 height=2/>
    </td>
    <td nowrap width="5%" class="listtblcolheader" align="center">Spent</td>
</tr>

<logic:equal name="form" property="invoiceType" value='<%=""+PrepareInvoiceForm.INVOICE_TASKS_GROUPED_BY_BILLING_TYPES%>'>
<logic:iterate name="report" property="columns" id="column" type="ReportColumn">
    <tr>
        <td bgcolor="#ffffff" class="reportrow3" align="center"><bean:write name="column" property="name"/></td>
        <td bgcolor="#ffffff" class="reportrow3">
        <logic:iterate name="report" property="rootEntry.childEntries" id="entry" type="ReportEntry">
            <% if(entry.getValue(column.getKey()).getValue() > 0) { %>
                <%=ResponseUtils.filter(entry.getFormattedName(":"))%>
                <br>
            <% } %>
        </logic:iterate>
        </td>
        <td bgcolor="#ffffff" class="reportrow3num" align="right">
        <%=TimeUtils.formatWorkDecimal( report.getRootEntry().getValue(column.getKey()).getValue() )%>
        </td>
    </tr>
</logic:iterate>
</logic:equal>

<logic:notEqual name="form" property="invoiceType" value='<%=""+PrepareInvoiceForm.INVOICE_TASKS_GROUPED_BY_BILLING_TYPES%>'>
<logic:iterate name="report" property="rootEntry.childEntries" id="entry" type="ReportEntry">
    <logic:iterate name="report" property="columns" id="column" type="ReportColumn">
    <% if(entry.getValue(column.getKey()).getValue() > 0) { %>
        <tr>
            <td bgcolor="#ffffff" class="reportrow3"><bean:write name="column" property="name"/></td>
            <td bgcolor="#ffffff" class="reportrow3">
                <%=ResponseUtils.filter(entry.getFormattedName(":"))%>
            </td>
            <td bgcolor="#ffffff" class="reportrow3num" align="right">
            <%=TimeUtils.formatWorkDecimal( entry.getValue(column.getKey()).getValue() )%>
            </td>
        </tr>
    <% } %>
    </logic:iterate>
</logic:iterate>
</logic:notEqual>

<tr>
    <td class="reportrow2" colspan="2" align="right">
        Total:
    </td>
    <td class="reportrow2num" align="right"><b>
        <%=TimeUtils.formatWorkDecimal( report.getRootEntry().getTotalValue().getValue() )%>
    </td>
</tr>
</table>
</td>
</tr>
</table>

<form>
<table width="770" align="center" cellspacing="0" cellpadding="7" border="0">
<tr>
    <td class="formbuttonpane" align="center">
        <!--input type="button" name="nomatter" value="Export for Quickbooks" onclick="document.location.href = document.location.href.replace('pageAction=html', 'pageAction=xml')"/-->
        <html:link page="/reports/prepareinvoice.do?pageAction=xml">
        <b></b>
        </html:link>
    </td>
</tr>
</table>
</form>

</body>
</html>
